﻿package fui.FUIComponents{
	import flash.events.*;
	import flash.display.Sprite;
	import fl.controls.*;
	import fl.containers.ScrollPane;
	import flash.text.TextFormat;
	import fl.data.DataProvider;
	import fui.FUIControllers.*;
	
	public class RankList extends Sprite implements IComponent{
		private var _comName:String = "Ranking List";
		private var _uis:UISession;
		private var _records:Array = new Array();
		private var _namelbl:Label;
		private var _namesList:List;
		private var _ranklbl:Label;
		private var _winsList:List;
		private var _total_cash:Label;
		private var _cashList:List;
		
		private var _offLeft:int;
		private var _offTop:int;
		
		public function RankList()
		{
			_offLeft = 50;
		    _offTop  = 30;
			createView();
			
		}
		private function createView():void{
			trace("Enter createView");
			var format:TextFormat = new TextFormat();
          	//format.font		      = "foo";
          	format.color          = 0x0F00FF;
          	format.size           = 16;
			format.italic = true;
			
			_namelbl = new Label();
			_namesList = new List();
			_ranklbl = new Label();
			_winsList = new List();
			_total_cash = new Label();
			_cashList = new List();
			trace("objects created ");
			_namelbl.x = _offLeft + 10;
			_namelbl.y = _offTop + 10;
			_namelbl.setSize(120, 30);
			_namelbl.text = "Player Name";
			_namelbl.setStyle("textFormat", format);
			addChild(_namelbl);
			_namesList.x = _offLeft + 10;
			_namesList.y = _offTop + 30;
			_namesList.setSize(120, 100);

			var rcView:FUIRecordView = new FUIRecordView(3, _offLeft, _offTop, 120);
			var dp:DataProvider = new DataProvider();
			dp.addItem({label:"Dalt", data:123});
			dp.addItem( {label:"Borel", data:124});
			_namesList.dataProvider = dp;
			//addChild(_namesList);
			_ranklbl.x = _offLeft + 130;
			_ranklbl.y = _offTop + 10;
			_ranklbl.text = "Total Wins";
			_ranklbl.setStyle("textFormat", format);
			addChild(_ranklbl);
			_winsList.x = _offLeft + 130;
			_winsList.y = _offTop + 30;
			_winsList.setSize(120, 100);
			var dpwl:DataProvider = new DataProvider();
			dpwl.addItem({label:"176"});
			dpwl.addItem( {label:"97"});
			_winsList.dataProvider = dpwl;
			//addChild(_winsList);
			_total_cash.x = _offLeft + 250;
			_total_cash.y = _offTop + 10;
			_total_cash.text  = "Total Cash";
			_total_cash.setStyle("textFormat", format);
			addChild(_total_cash);
			_cashList.x = _offLeft + 250;
			_cashList.y = _offTop + 30;
			_cashList.setSize(120, 100);
			var dpcl:DataProvider = new DataProvider();
			dpcl.addItem({label:"176042"});
			dpcl.addItem( {label:"107102"});
			_cashList.dataProvider = dpcl;
			//addChild(_cashList);
			var tmparr:Object = new Object();
			tmparr.p0 = dp;
			tmparr.p1 = dpwl;
			tmparr.p2 = dpcl;

			
			trace("before set data providers");
			rcView.setData(tmparr);
			trace("After set data provider");
			addChild(rcView);
		}
		public function set_xml_source(xml_path:String):void
		{
			//TODO:
		}
		public function set_session(uis:UISession):void
		{
			this._uis = uis;
		}
		public function get_component_title():String
		{
			return this._comName;
		}
        public function show_component():void
		{
			//TODO:
			visible = true;
		}
		
		public function hide_component():void
		{
			//TODO:
			visible = false;
		}
		public function if_need_auth():Boolean
		{
			//TODO:
			return true;
		}
		public function self_remove():void
		{
			//TODO:
		}
	}
}